home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / toollib / tool.doc < prev    next >
Text File  |  1995-12-30  |  42KB  |  1,184 lines

  1.  
  2.                        tool.library version 8.1
  3.                   © Copyright 1990-91 Jaba Development
  4.            written with the Devpac Assembler version 2.14 by
  5.                          Jan van den Baard
  6.  
  7.  
  8.  DISCLAIMER
  9.  ----------------------------------------------------------------------------
  10.  The author takes no responsibility as to the suitability or accuracy of this
  11.  documentation and/or the program(s) it describes. Any damage sustained by the
  12.  use of  this documentation and/or  the program(s) it  describes is  the sole
  13.  responsibility of the user her/him self.
  14.  ----------------------------------------------------------------------------
  15.  
  16.  COPYRIGHT
  17.  ----------------------------------------------------------------------------
  18.  tool.library, © Copyright 1990-91 by Jaba Development.  All rights reserved.
  19.  This program may be  distributed  non-commercially  only  providing that the
  20.  source code, documentation and copyright notice remains intact. This program
  21.  is FREEWARE so no financial donation is necessary (but welcome).
  22.  ----------------------------------------------------------------------------
  23.  
  24.  This is version 8.1 of a shared library containing 46 useful functions  for
  25.  all kinds of programs.  The functions in this library are not of a  specific
  26.  kind but cover a lot of the Amiga facilities. There are functions for ports
  27.  , sorting, gadgets, memory, string, directory and file handling. This manual
  28.  is divided into the following sections:
  29.  
  30.     THE ROUTINES                    I.
  31.     STRUCTURES AND DEFINITIONS      II.
  32.     THE FILEREQUESTER               III.
  33.     HISTORY                         IV.
  34.     NOTES                           V.
  35.  
  36.  ----------------------------------------------------------------------------
  37.                               I. THE ROUTINES
  38.  ----------------------------------------------------------------------------
  39.  NAME
  40.         Port = CreatePort( Name, Pri );
  41.          D0       -30       A0   D0
  42.  
  43.  FUNCTION
  44.         To allocate and set up a message port.
  45.  
  46.  INPUTS
  47.         Name - A pointer to a NULL terminated string representing the
  48.                name of the message port or NULL if the port should not
  49.                be globaly recognizable to other tasks.
  50.  
  51.         Pri  - A 32 bit integer representing the message port priority.
  52.  
  53.  RESULT
  54.         "Port" will be a pointer to the newly created message port or
  55.         NULL if an error occurred.
  56.         NOTE: The message port is only added to the system port-list if
  57.               you specify a name for it. If you don't the port can not
  58.               be found by other tasks.
  59.  
  60.  NAME
  61.         DeletePort( Port );
  62.            -36       A0
  63.  
  64.  FUNCTION
  65.         To deallocate and remove a message port.
  66.  
  67.  INPUTS
  68.         Port - A pointer to the message port that is to be deleted.
  69.  
  70.  RESULT
  71.         The message port is removed and deallocated.
  72.  
  73.  NAME
  74.         IOReq = CreateExtIO( Port, Size );
  75.          D0        -42        A0    D0
  76.  
  77.  FUNCTION
  78.         To allocates and initialize an IORequest structure.
  79.  
  80.  INPUTS
  81.         Port - A pointer to the message port which is signalled if a message
  82.                is executed.
  83.  
  84.         Size - A 32 bit integer that represents the size if the IORequest
  85.                structure.
  86.  
  87.  RESULT
  88.         "IOReq" will be a pointer to the allocated and initialized IORequest
  89.         structure or NULL if an error occurred.
  90.  
  91.  NAME
  92.         DeleteExtIO( IOReq );
  93.            -48        A0
  94.  
  95.  FUNCTION
  96.         To deallocate an IORequest structure.
  97.  
  98.  INPUTS
  99.         IOReq - A pointer to the IORequest structure to be deallocated.
  100.  
  101.  NAME
  102.         IOReq = CreateStdIO( Port );
  103.          D0        -54        A0
  104.  
  105.  FUNCTION
  106.         To allocate and initialize an IOStdReq structure.
  107.  
  108.  INPUTS
  109.         Port - A pointer to the message port which is signalled if a message
  110.                is executed.
  111.  
  112.  RESULT
  113.         "IOReq" will be a pointer to the allocated and initialized IOStdReq
  114.         structure or NULL if an error occurred.
  115.  
  116.  NAME
  117.         DeleteStdIO( IOReq );
  118.            -60        A0
  119.  
  120.  FUNCTION
  121.         To deallocate an IOStdReq structure.
  122.  
  123.  INPUTS
  124.         IOReq - A pointer to the IOStdReq structure to be deallocated.
  125.  
  126.  NAME
  127.         timedelay = CreateTimeDelay(port,seconds,micros);
  128.             D0            -66        A0     D0     D1
  129.  
  130.  FUNCTION
  131.         Sets up the timer.device to be able to put a task to sleep for a
  132.         precise amount of time.
  133.  
  134.  INPUTS
  135.         port    - A pointer to a message port which, if this port was
  136.                   signalled, wakes up the task before the time ran out.
  137.                   This may also be NULL but that makes it impossible to
  138.                   stop the delay before the time runs out.
  139.  
  140.         seconds - A 32-bit integer representing the amount of seconds to
  141.                   put the task to sleep.
  142.  
  143.         micros  - A 32-bit integer representing the amount of microseconds
  144.                   to put the task to sleep.
  145.  
  146.  RESULT
  147.         timedelay - A pointer to a TimeDelay structure or NULL if an error
  148.                     occurred.
  149.  
  150.  NAME
  151.         yourmsg = DoTimeDelay(timedelay);
  152.                      -72        A0
  153.  
  154.  FUNCTION
  155.         To put a task to sleep for a specific time.
  156.  
  157.  INPUTS
  158.         timdelay - A pointer to a TimeDelay structure as returned by
  159.                    "CreateTimeDelay".
  160.  
  161.  RESULT
  162.         "yourmsg" will be TRUE if the routine breaks off because it has
  163.         been signalled by the message port supplied by you and FALSE if
  164.         the time ran out.
  165.  
  166.  NAME
  167.         DeleteTimeDelay(timedelay);
  168.               -78          A0
  169.  
  170.  FUNCTION
  171.         To deallocate and erase the TimeDelay structure and close all of it's
  172.         resources.
  173.  
  174.  INPUTS
  175.         timdelay - A pointer to a TimeDelay structure as returned by
  176.                    "CreateTimeDelay".
  177.  
  178.  NAME
  179.         QuickSort( Base, Num, Size, Compar );
  180.            -84      A0   D0    D1     A1
  181.  
  182.  FUNCTION
  183.         To sort an array of elements.
  184.  
  185.  INPUTS
  186.         Base   - A pointer to the first element in the array.
  187.  
  188.         Num    - A 32 bit integer representing the number of elements in the
  189.                  array.
  190.  
  191.         Size   - A 32 bit integer representing the size of an element.
  192.                  NOTE: The size of an element may NOT be larger than 64
  193.                        KBytes.
  194.  
  195.         Compar - A pointer to a routine that does the comparison between
  196.                  two elements. This is called like this:
  197.  
  198.                  Compar(a,b);
  199.  
  200.                  The arguments "a" and "b" are pushed on the stack before
  201.                  calling the routine. Also a pointer to argument "a" is put
  202.                  in A0 and a pointer to argument "b" is put in A1 for the
  203.                  assembler programmers. The routine must return a 32 bit
  204.                  integer. It should return -1, 0 or 1 depending on whether
  205.                  element "a" is to be considered smaller, equal or bigger than
  206.                  element "b". The comparison routine is passed POINTERS to
  207.                  the elements in the array.
  208.  
  209.  NAME
  210.         SwapMem( MemA, MemB, Size );
  211.           -90     A0    A1    D0
  212.  
  213.  FUNCTION
  214.         To exchange two areas of memory.
  215.  
  216.  INPUTS
  217.         MemA - A pointer to the first block of memory.
  218.  
  219.         MemB - A pointer to the second block of memory.
  220.  
  221.         Size - A 32 bit integer representing the size in bytes of the two
  222.                memory areas.
  223.  
  224.         NOTE: The memory areas swapped can NOT be larger than 64 KByte.
  225.  
  226.  NAME
  227.         Set = TestBits( Value, Bits );
  228.         D0       -96      D0    D1
  229.  
  230.  FUNCTION
  231.         To test whether or not certain bits are set in a value.
  232.  
  233.  INPUTS
  234.         Value - A 32 bit integer representing the value in which the bits
  235.                 are tested.
  236.  
  237.         Bits  - A 32 bit integer representing the bits to be tested.
  238.  
  239.  RESULT
  240.         Set will be TRUE if the bits where set in "Value" and FALSE if not.
  241.  
  242.  NAME
  243.         SelectGadget( Window, Gadget, Req );
  244.             -102        A0      A1    A2
  245.  
  246.  FUNCTION
  247.         To visually select a gadget. Also the SELECTED flag in the "Flags"
  248.         field of the gadget will be set.
  249.  
  250.  INPUTS
  251.         Window - A pointer to the window in which the gadget is located.
  252.  
  253.         Gadget - A pointer to the gadget which must be selected.
  254.                  NOTE: Only gadget of the "TOGGLESELECT" type will be
  255.                        selected.
  256.  
  257.         Req    - If the gadget is located in a requester you must put a
  258.                  pointer to that requester here. If no requester is used
  259.                  put NULL here.
  260.  
  261.  NAME
  262.         DeSelectGadget( Window, Gadget, Req );
  263.               -108        A0      A1    A2
  264.  
  265.  FUNCTION
  266.         To visually select a gadget. Also the SELECTED flag in the "Flags"
  267.         field of the gadget will be cleared.
  268.  
  269.  INPUTS
  270.         Window - A pointer to the window in which the gadget is located.
  271.  
  272.         Gadget - A pointer to the gadget which must be de-selected.
  273.                  NOTE: Only gadget of the "TOGGLESELECT" type will be
  274.                        de-selected.
  275.  
  276.         Req    - If the gadget is located in a requester you must put a
  277.                  pointer to that requester here. If no requester is used
  278.                  put NULL here.
  279.  
  280.  NAME
  281.         MutualExclude( Window, Gadget, From, Req );
  282.              -114        A0      A1     A2   A3
  283.  
  284.  FUNCTION
  285.         To mutually exclude gadgets if a certain gadget is selected.
  286.  
  287.  INPUTS
  288.         Window - A pointer to the window in which the gadgets are located.
  289.  
  290.         Gadget - A pointer to the gadget which does the MutualExcluding.
  291.                  The "MutualExclude" field of this gadget represents the
  292.                  gadgets to be mutually excluded. Every set bit represents
  293.                  a gadget that should be de-selected if this gadget is
  294.                  selected.
  295.  
  296.         From   - A pointer to the first gadget in a list from which the
  297.                  routine starts to look for gadgets to be de-selected.
  298.                  NOTE: Only gadgets of the "TOGGLESELECT" type will be
  299.                        mutually excluded.
  300.  
  301.         Req    - If the gadgets are located in a requester you must put a
  302.                  pointer to that requester here. If no requester is used
  303.                  put NULL here.
  304.  
  305.  NAME
  306.         MutualInclude( Window, Gadget, From, Req );
  307.              -120        A0      A1     A2   A3
  308.  
  309.  FUNCTION
  310.         To mutually include gadgets if a certain gadget is selected.
  311.  
  312.  INPUTS
  313.         Window - A pointer to the window in which the gadgets are located.
  314.  
  315.         Gadget - A pointer to the gadget which does the MutualIncluding.
  316.                  The "MutualExclude" field of this gadget represents the
  317.                  gadgets to be mutually included. Every set bit represents
  318.                  a gadget that should be selected if this gadget is
  319.                  selected.
  320.  
  321.         From   - A pointer to the first gadget in a list from which the
  322.                  routine starts to look for gadgets to be selected.
  323.                  NOTE: Only gadgets of the "TOGGLESELECT" type will be
  324.                        mutually included.
  325.  
  326.         Req    - If the gadgets are located in a requester you must put a
  327.                  pointer to that requester here. If no requester is used
  328.                  put NULL here.
  329.  
  330.  NAME
  331.         EraseGadget( Window, Gadget, Req );
  332.            -126        A0      A1    A2
  333.  
  334.  FUNCTION
  335.         To erase a gadget from the window or requester.
  336.  
  337.  INPUTS
  338.         Window - A pointer to the window in which the gadget is located.
  339.  
  340.         Gadget - A pointer to the gadget which must be erased.
  341.  
  342.         Req    - If the gadget is located in a requester you must put a
  343.                  pointer to that requester here. If no requester is used
  344.                  put NULL here.
  345.  
  346.  NAME
  347.         GadgetOn( Window, Gadget, Req );
  348.           -132      A0      A1    A2
  349.  
  350.  FUNCTION
  351.         To enable a gadget to be being clicked.
  352.         It's basically the same as Intuition's "OnGadget" only this
  353.         routine first erases the gadget from the display and then refreshes
  354.         only the gadget switched on.
  355.  
  356.  INPUTS
  357.         Window - A pointer to the window in which the gadget is located.
  358.  
  359.         Gadget - A pointer to the gadget which must be switched on.
  360.  
  361.         Req    - If the gadget is located in a requester you must put a
  362.                  pointer to that requester here. If no requester is used
  363.                  put NULL here.
  364.  
  365.  NAME
  366.         GadgetOff( Window, Gadget, Req );
  367.            -138      A0      A1    A2
  368.  
  369.  FUNCTION
  370.         To disable a gadget from being clicked.
  371.         It's basically the same as Intuition's "OffGadget" only this
  372.         routine first erases the gadget from the display and then refreshes
  373.         only the gadget switched off.
  374.  
  375.  INPUTS
  376.         Window - A pointer to the window in which the gadget is located.
  377.  
  378.         Gadget - A pointer to the gadget which must be switched off.
  379.  
  380.         Req    - If the gadget is located in a requester you must put a
  381.                  pointer to that requester here. If no requester is used
  382.                  put NULL here.
  383.  
  384.  NAME
  385.         sel = SelectTest( Gadget );
  386.         D0       -144       A0
  387.  
  388.  FUNCTION
  389.         To test if a gadget is selected or not.
  390.  
  391.  INPUTS
  392.         Gadget - A pointer to the gadget which is tested.
  393.  
  394.  RESULTS
  395.         "sel" will be TRUE if the gadget is selected and FALSE if not.
  396.  
  397.  NAME
  398.         ShadowGadget( Window, Gadget, Req, Color );
  399.             -150        A0      A1    A2    D0
  400.  
  401.  FUNCTION
  402.         To draw a shadow around the gadget in the specified color.
  403.  
  404.  INPUTS
  405.         Window - A pointer to the window in which the gadget is located.
  406.  
  407.         Gadget - A pointer to the gadget at which a shadow is drawed.
  408.  
  409.         Req    - If the gadget is located in a requester you must put a
  410.                  pointer to that requester here. If no requester is used
  411.                  put NULL here.
  412.  
  413.         Color  - A 32 bit integer representing the pen number in which the
  414.                  shadow is drawed.
  415.  
  416.  NAME
  417.         OnGList( Window, First, Req, Numgad );
  418.           -156     A0     A1    A2     D0
  419.  
  420.  FUNCTION
  421.         To switch a complete list of gadgets on.
  422.  
  423.  INPUTS
  424.         Window - See GadgetOn
  425.  
  426.         First  - A pointer to the first gadget in the list to be switched on.
  427.  
  428.         Req    - See GadgetOn
  429.  
  430.         NumGad - A 32 bit integer representing the number of gadgets to be
  431.                  switch on. If you put -1 here all the gadgets in the list
  432.                  are switched on.
  433.  
  434.  NAME
  435.         OffGList( Window, First, Req, Numgad );
  436.           -162      A0     A1    A2     D0
  437.  
  438.  FUNCTION
  439.         To switch a complete list of gadgets off.
  440.  
  441.  INPUTS
  442.         Window - See GadgetOff
  443.  
  444.         First  - A pointer to the first gadget in the list to be switched off.
  445.  
  446.         Req    - See GadgetOff
  447.  
  448.         NumGad - A 32 bit integer representing the number of gadgets to be
  449.                  switch off. If you put -1 here all the gadgets in the list
  450.                  are switched off.
  451.  
  452.  NAME
  453.         SelectGList( Window, First, Req, Numgad );
  454.            -168        A0     A1    A2     D0
  455.  
  456.  FUNCTION
  457.         To select a complete list of gadgets.
  458.  
  459.  INPUTS
  460.         Window - See SelectGadget
  461.  
  462.         First  - A pointer to the first gadget in the list to be selected.
  463.                  NOTE: Only gadget of the "TOGGLESELECT" type can be
  464.                        selected.
  465.  
  466.         Req    - See SelectGadget
  467.  
  468.         NumGad - A 32 bit integer representing the number of gadgets to be
  469.                  selected. If you put -1 here all the gadgets in the list
  470.                  are selected.
  471.  
  472.  NAME
  473.         DeSelectGList( Window, First, Req, Numgad );
  474.             -174         A0     A1    A2     D0
  475.  
  476.  FUNCTION
  477.         To de-select a complete list of gadgets.
  478.  
  479.  INPUTS
  480.         Window - See DeSelectGadget
  481.  
  482.         First  - A pointer to the first gadget in the list to be de-selected.
  483.                  NOTE: Only gadget of the "TOGGLESELECT" type can be
  484.                        de-selected.
  485.  
  486.         Req    - See DeSelectGadget
  487.  
  488.         NumGad - A 32 bit integer representing the number of gadgets to be
  489.                  de-selected. If you put -1 here all the gadgets in the list
  490.                  are de-selected.
  491.  
  492.  NAME
  493.         ShadowGList( Window, First, Req, Color, Numgad );
  494.             -180       A0     A1    A2    D0      D1
  495.  
  496.  FUNCTION
  497.         To draw shadows around a complete list of gadgets.
  498.  
  499.  INPUTS
  500.         Window - See ShadowGadget
  501.  
  502.         First  - A pointer to the first gadget in the list to be shadowed.
  503.  
  504.         Req    - See ShadowGadget
  505.  
  506.         Color  - See ShadowGadget
  507.         NumGad - A 32 bit integer representing the number of gadgets to be
  508.                  shadowed. If you put -1 here all the gadgets in the list
  509.                  are shadowed.
  510.  
  511.  NAME
  512.         EraseGList( Window, First, Req, Numgad );
  513.             -186       A0     A1    A2    D0
  514.  
  515.  FUNCTION
  516.         To erase a complete list of gadgets from a window or a requester.
  517.  
  518.  INPUTS
  519.         Window - See EraseGadget
  520.  
  521.         First  - A pointer to the first gadget in the list to be erased.
  522.  
  523.         Req    - See EraseGadget
  524.  
  525.         NumGad - A 32 bit integer representing the number of gadgets to be
  526.                  erased. If you put -1 here all the gadgets in the list
  527.                  are erased.
  528.  
  529.  NAME
  530.         InitMemoryChain(chain,size)
  531.               -192       A0    D0
  532.  
  533.  FUNCTION
  534.         To initialize a MemoryChain structure for use.
  535.  
  536.  INPUTS
  537.         chain - A pointer to a MemoryChain structure.
  538.  
  539.         size  - A 32-bit integer representing the size of a MemoryBlock.
  540.  
  541.  NAME
  542.         memptr = AllocItem(chain,size,reqs);
  543.           D0       -198      A0   D0   D1
  544.  
  545.  FUNCTION
  546.         To allocate a chunk of memory in a MemoryChain.
  547.  
  548.  INPUTS
  549.         chain - A pointer to the MemoryChain in which the memory will be
  550.                 allocated.
  551.  
  552.         size  - A 32-bit integer representing the size of the memory.
  553.  
  554.         reqs  - A 32-bit integer representing the memory requirements
  555.                 of the allocation.
  556.  
  557.         NOTE: The size is always rounded up to the nearest multiple of 8.
  558.  
  559.  RESULT
  560.         memptr - A pointer to the allocated memory or NULL if the allocation
  561.                  failed.
  562.         NOTE: The memory is always allocated in a longword boundary.
  563.  
  564.  NAME
  565.         FreeItem(chain,memptr,size)
  566.           -204     A0    A1    D0
  567.  
  568.  FUNCTION
  569.         To deallocate a chunk of memory allocated with AllocItem from a
  570.         MemoryChain.
  571.  
  572.  INPUTS
  573.         chain  - A pointer to the MemoryChain in which the memory was
  574.                  allocated.
  575.  
  576.         memptr - A pointer to the memory.
  577.  
  578.         size   - A 32 bit integer representing the size to be freed.
  579.  
  580.  NAME
  581.         FreeMemoryChain(chain)
  582.              -210        A0
  583.  
  584.  FUNCTION
  585.         To deallocate and re-initialize a complete MemoryChain.
  586.  
  587.  INPUTS
  588.         chain - A pointer to the MemoryChain
  589.  
  590.  RESULT
  591.         All memory allocated for the MemoryChain is deallocated and the
  592.         MemoryChain structure itself is re-initialized so that it can
  593.         be used again.
  594.  
  595.  NAME
  596.         Format( Buffer, FString, Args );
  597.         -216      A0      A1      A2
  598.  
  599.  FUNCTION
  600.         To format an output into a specified buffer.
  601.  
  602.  INPUTS
  603.         Buffer  - A pointer to a buffer in which the formatted output is
  604.                   copied. NOTE: You must make sure that the buffer is big
  605.                   enough to hold the formatted output.
  606.  
  607.         FString - A pointer to a NULL terminated string explaining how to
  608.                   interpret the arguments. The following format specifiers
  609.                   are supported:
  610.  
  611.                     %lc - the next long word in the argument array is
  612.                           formatted as a 8 bit character.
  613.  
  614.                     %ld - the next long word in the argument array is
  615.                           formatted as a 32 bit decimal number.
  616.  
  617.                     %lx - the next long word in the argument array is
  618.                           formatted as a 32 bit hexadecimal number.
  619.  
  620.                     %ls - the next long word in the argument array is
  621.                           formatted as a pointer to a NULL terminated
  622.                           string.
  623.  
  624.                   The "l" in these format specifiers is only necessary
  625.                   when the arguments are 32 bit. Following this "l" sign
  626.                   you may also specify the following:
  627.  
  628.                   -> An optional minus sign to tell the routine to left
  629.                      justify the next formatted item within the field
  630.                      width
  631.  
  632.                   -> An optional digit string to tell the routine to fill
  633.                      out the formatted item with spaces. If the digit string
  634.                      is preceeded with a "0" character the item will be
  635.                      filled out with "0" characters instead of spaces.
  636.  
  637.                   -> An optional period sign to separate the field width
  638.                      specifier from the maximum characters specifier.
  639.  
  640.                   -> An optional digit string (for %ls and %s only) to tell
  641.                      the routine the maximum amount of characters to format
  642.                      from the string.
  643.  
  644.                   This routine is based on Exec's function "RawDoFmt()" which
  645.                   does NOT support any form of floating point formatting.
  646.                   If you have to format floating point numbers you will have
  647.                   to use "sprintf" from the standard C library.
  648.  
  649.         Args    - A pointer to an array in which the arguments are stored.
  650.                   NOTE: C programmers must link with "tool.lib" to get the
  651.                         arguments passed correctly to the routine.
  652.  
  653.  NAME
  654.         num = WriteFormat( Handle, FString, Args );
  655.         D0       -222        A0       A1     A2
  656.  
  657.  FUNCTION
  658.         To format an output and writes the result directly to a file.
  659.  
  660.  INPUTS
  661.         Handle  - A pointer to an AmigaDOS filehandle to which the formatted
  662.                   result will be written.
  663.  
  664.         FString - A pointer to a NULL terminated format string which can
  665.                   hold the same format specifiers as the format string from
  666.                   "Format". NOTE: The formatted output may NOT be larger
  667.                   that 512 bytes (including the terminating 0 byte.).
  668.  
  669.         Args    - A pointer to an array in which the arguments are stored.
  670.                   NOTE: C programmers must link with "tool.lib" to get the
  671.                         arguments passed correctly to the routine.
  672.  
  673.  RESULT
  674.         "num" will read the exact amount of characters written to the file or
  675.         -1 if an error occurred.
  676.  
  677.  NAME
  678.         match = MatchPattern( String, Pattern, Case );
  679.          D0        -228         A0      A1      D0
  680.  
  681.  FUNCTION
  682.         To perform a Unix style pattern match on a string.
  683.  
  684.  INPUTS
  685.         String  - A pointer to a NULL terminated string which will be matched
  686.                   with the pattern.
  687.  
  688.         Pattern - A pointer to a NULL terminated string which represents
  689.                   the pattern to be matched. The pattern may have the
  690.                   following wildcards:
  691.  
  692.                     "*" - representing any number of characters.
  693.                     "?" - representing a single character.
  694.  
  695.         Case    - A 32 bit boolean value which must be "CASE" if the routine
  696.                   should also check the character case and "NO_CASE" if not.
  697.  
  698.  RESULT
  699.         "match" will read TRUE if the string matched the pattern and FALSE
  700.         if not.
  701.  
  702.  NAME
  703.         pat = Isolate( Path, Buffer );
  704.         D0     -234     A0     A1
  705.  
  706.  FUNCTION
  707.         To scan a full pathname for a wildcard expansion and copy it, if
  708.         found, into a buffer.
  709.  
  710.  INPUTS
  711.         Path   - A pointer to a NULL terminated full AmigaDOS pathname.
  712.                  If a pattern was found at the end of the pathname this
  713.                  pattern will be copied into the buffer and the pathname
  714.                  will be truncated at the point where the pattern was found.
  715.                  NOTE: This routine only isolates patterns which has atleast
  716.                        one wildcard in it.
  717.  
  718.         Buffer - A pointer to a buffer in which the pattern, if found, is
  719.                  copied.
  720.  
  721.  RESULT
  722.         "pat" will be TRUE if a pattern was found and FALSE if not.
  723.  
  724.  NAME
  725.         BstrToCstr( Bstr, Buffer );
  726.            -240      A0     A1
  727.  
  728.  FUNCTION
  729.         To convert a BSTR string into a standard NULL terminated string.
  730.  
  731.  INPUTS
  732.         Bstr   - A BPTR to a BSTR string.
  733.  
  734.         Buffer - A buffer in which the string is copied.
  735.  
  736.  NAME
  737.         return = GetDate( DateStamp, Buffer, How);
  738.           D0      -246       A0        A1     D0
  739.  
  740.  FUNCTION
  741.         To convert a "DateStamp" structure into an ASCII string.
  742.  
  743.  INPUTS
  744.         DateStamp - A pointer to an initialized DateStamp structure
  745.                     or NULL for the current System time.
  746.  
  747.         Buffer    - A pointer to a buffer which can hold atleast "MINDATE"
  748.                     bytes.
  749.  
  750.         How       - A 32 bit integer explaining what to convert.
  751.                     For example lets say that it is thursday 20 september
  752.                     1990 and it's 13:30:00 hour.
  753.  
  754.                     The result after a call to GetDate will be:
  755.                     ALL        - Thursday 20-09-1990 13:30:00
  756.                     ONLY_DAY   - Thursday
  757.                     ONLY_DATE  - 20-09-1990
  758.                     ONLY_TIME  - 13:30:00
  759.  
  760.  RESULTS
  761.         return will be TRUE if the conversion succeeded or FALSE if it failed
  762.         "Buffer" contains the converted ASCII form of "DateStamp" or the
  763.         System time.
  764.  
  765.  NAME
  766.         succes = OpenDir(directory,name);
  767.           D0      -252      A0      A1
  768.  
  769.  FUNCTION
  770.         To open a directory.
  771.  
  772.  INPUTS
  773.         directory - A pointer to a Directory structure.
  774.  
  775.         name      - A pointer to a NULL terminated string representing the
  776.                     name of the directory.
  777.  
  778.  RESULT
  779.         success - this reads TRUE if the directory opens successfully and
  780.                   FALSE if an error occurred.
  781.  
  782.  NAME
  783.         entry = GetEntry(directory);
  784.          D0       -258      A0
  785.  
  786.  FUNCTION
  787.         To read the next entry of the directory into memory.
  788.  
  789.  INPUTS
  790.         directory - A pointer to the Directory structure.
  791.  
  792.  RESULT
  793.         entry - this will be a pointer to an EntryInfo structure or NULL.
  794.                 If NULL is returned this could mean that an error occurred.
  795.                 A call to IoErr should read ERROR_NO_MORE_ENTRIES otherwise
  796.                 an error has occurred.
  797.                 NOTE: The directory is automatically UnLocked when the last
  798.                       entry was read.
  799.  
  800.  NAME
  801.         CloseDir(directory)
  802.           -264      A0
  803.  
  804.  FUNCTION
  805.         To UnLock the directory.
  806.  
  807.  INPUTS
  808.         directory - A pointer to the directory structure.
  809.  
  810.  NAME
  811.         FreeDir(directory);
  812.          -270      A0
  813.  
  814.  FUNCTION
  815.         To deallocate the memory a directory takes up.
  816.  
  817.  INPUTS
  818.         directory - A pointer to the directory structure.
  819.  
  820.  NAME
  821.         string = IoErrToStr()
  822.           D0       -276
  823.  
  824.  FUNCTION
  825.         To convert a DOS error into an ASCII form.
  826.  
  827.  RESULTS
  828.         string - this will be a pointer to a string representing the ASCII
  829.                  form of a DOS error or NULL if IoErr returned an unknown
  830.                  code.
  831.  
  832.  NAME
  833.         Freq = AllocFreq();
  834.          D0      -282
  835.  
  836.  FUNCTION
  837.         To allocate and initialize a FileRequester structure.
  838.  
  839.  RESULT
  840.         Freq - this will be a pointer to an allocated and initialized
  841.         FileRequester structure or NULL if the Allocation failed.
  842.  
  843.  NAME
  844.         FreeFreq( Freq );
  845.           -288     A0
  846.  
  847.  FUNCTION
  848.         To deallocate a filerequester structure.
  849.  
  850.  INPUTS
  851.         Freq - A pointer to the FileRequester structure you want
  852.                deallocated.
  853.  
  854.  NAME
  855.         error = FileRequest( Freq );
  856.                    -294       A0
  857.  
  858.  FUNCTION
  859.         To put up the filerequester.
  860.  
  861.  INPUTS
  862.         Freq - A pointer to an allocated and initialized FileRequester
  863.                structure.
  864.  
  865.  RESULT
  866.         error - this will be an error code explained in "THE FILEREQUESTER"
  867.         chapter of this documentation.
  868.  
  869.  NAME
  870.         num = FormatText( RPort, FString, Args );
  871.         D0       -300      A0       A1     A2
  872.  
  873.  FUNCTION
  874.         To format a string and write it in a rastport.
  875.  
  876.  INPUTS
  877.         Handle  - A valid pointer to a RastPort.
  878.  
  879.         FString - A pointer to a NULL terminated format string which can
  880.                   hold the same format specifiers as the format string from
  881.                   "Format". NOTE: The formatted output may NOT be larger
  882.                   that 512 bytes (including the terminating 0 byte.).
  883.  
  884.         Args    - A pointer to an array in which the arguments are stored.
  885.                   NOTE: C programmers must link with "tool.lib" to get the
  886.                         arguments passed correctly to the routine.
  887.  
  888.  RESULT
  889.         "num" will read the amount formatted characters written to the
  890.         rastport or NULL if an error occurred.
  891.  
  892.  ----------------------------------------------------------------------------
  893.                        II. STRUCTURES AND DEFINITIONS
  894.  ----------------------------------------------------------------------------
  895.  A pointer to the ToolBase structure is returned upon a successful call to
  896.  OpenLibrary().
  897.  
  898.  struct ToolBase
  899.  {
  900.   struct Library        LibNode;        The actual library structure.
  901.   struct ExecBase      *SysBase;        A pointer to ExecBase.
  902.   struct DosLibrary    *DOSBase;        A pointer to DOSBase.
  903.   struct IntuitionBase *IntuitionBase;  A pointer to IntuitionBase.
  904.   struct GfxBase       *GfxBase;        A pointer to GfxBase.
  905.   LONG                  SegList;        A BPTR to the library code.
  906.  };
  907.  
  908.  The library-base pointers in this structure can be used by a program to call
  909.  upon functions of any of those libraries.
  910.  
  911.  A pointer to the TimeDelay structure is returned upon a successful call to
  912.  CreateTimeDelay().
  913.  
  914.  struct TimeDelay
  915.  {
  916.   struct MsgPort     *td_UserPort;     A pointer to your message port.
  917.   struct MsgPort     *td_ReplyPort;    Used by the timer.device.
  918.   struct timerequest *td_TimeRequest;  To specify the delay
  919.  };
  920.  
  921.  
  922.  The MemoryBlock, MemoryItem, BlockList and ItemList structures are used
  923.  internally to hold all allocations together in a MemoryChain structure.
  924.  
  925.  struct MemoryChain
  926.  {
  927.   struct BlockList  mc_Blocks;        The list of blocks in the chain.
  928.   struct ItemList   mc_Items;         The list of items in the chain.
  929.   ULONG             mc_BlockSize;     The size of a block.
  930.  };
  931.  
  932.  The Directory structure is used to hold the entries of a directory
  933.  together.
  934.  
  935.  struct Directory
  936.  {
  937.   struct EntryInfo     *dr_First;       The first entry in the directory.
  938.   struct EntryInfo     *dr_End;         Always NULL.
  939.   struct EntryInfo     *dr_Last;        The last entry in the directory.
  940.   struct FileInfoBlock *dr_InfoBlock;   Used to read the entries.
  941.   BPTR                  dr_Lock;        Used to read the entries.
  942.   ULONG                 dr_NumEntries;  The number of entries in the dir.
  943.   struct MemoryChain    dr_DirMem;      The memory used up.
  944.  };
  945.  
  946.  The EntryInfo structure describes the entry.
  947.  
  948.  struct EntryInfo
  949.  {
  950.   struct EntryInfo  *ei_Next;           The next entry.
  951.   struct EntryInfo  *ei_Previous;       The previous entry.
  952.   USHORT             ei_Type;           The type of entry (see below)
  953.   UBYTE              ei_Name[32];       The entry name.
  954.   LONG               ei_SizeBytes;      The size in bytes (only with files)
  955.   LONG               ei_SizeBlocks;     The size in blocks (only with files)
  956.   LONG               ei_ProtectionBits; The protection bits
  957.   struct DateStamp   ei_Date;           The entry date (not for devices)
  958.  };
  959.  
  960.  The TOOL_VERSION and TOOL_REVISION defines represent the version and
  961.  revision number of the tool.library.
  962.  
  963.  The LONGALLIGN macro is used by the library memory routines to make the
  964.  size of the allocation even to a 8 byte boundary.
  965.  
  966.  MINDATE   is a constant that represents the largest possible output of
  967.            GetDate().
  968.  ALL       tells GetDate to convert the complete date.
  969.  ONLY_DAY  tells GetDate only to convert the day of the week.
  970.  ONLY_DATE tells GetDate only to convert the date.
  971.  ONLY_TIME tells GetDate only to convert the time.
  972.  
  973.  NO_CASE   tells MatchPattern to check the character case also.
  974.  CASE      tells MatchPattern not to check the character case.
  975.  
  976.  ENTRY_FILE  the entry is a file.
  977.  ENTRY_DIR   the entry is a directory.
  978.  ENTRY_DEV   the entry is a device. (only used by the FileRequester)
  979.  
  980.  DIRBLOCK    The size of a MemoryBlock in a directory.
  981.  
  982.  ----------------------------------------------------------------------------
  983.                           III. THE FILEREQUESTER
  984.  ----------------------------------------------------------------------------
  985.  Before  you  can call the  FileRequester you must first  call "AllocFreq" to
  986.  allocate and initialize a FileRequester structure and it's buffers.   If the
  987.  allocation  succeeded you will  be returned a  pointer to the following data
  988.  structure:
  989.  
  990.             struct FileRequester
  991.             {
  992.                 char             *fr_HeadLine;
  993.                 char             *fr_FileName;
  994.                 char             *fr_DirName;
  995.                 char             *fr_DontShow;
  996.                 USHORT            fr_LeftEdge;
  997.                 USHORT            fr_TopEdge;
  998.                 struct Window    *fr_Caller;
  999.                 struct Screen    *fr_Screen;
  1000.                 struct Directory *fr_Directory;
  1001.                 USHORT            fr_Flags;
  1002.                 USHORT            fr_Colors[4];
  1003.                 BPTR              fr_Handle;
  1004.                 LONG              fr_Reserved;
  1005.             };
  1006.  
  1007.  The  "fr_HeadLine"  field points to a buffer in which you can copy the title
  1008.  of the FileRequester window with a maximum of 28 bytes.
  1009.  
  1010.  The "fr_FileName" field points to a buffer in which you can copy the default
  1011.  filename. A maximum  of 32 bytes is allowed here. After the FileRequester is
  1012.  closed  the last  selected filename can be found in this buffer.
  1013.  
  1014.  The "fr_DirName"  field points to a buffer in which you can copy the default
  1015.  pathname with or without a wildcard expansion.  A maximum  of 256  bytes  is
  1016.  allowed here. After the FileRequester is closed  the last  selected pathname
  1017.  can be found in this buffer.
  1018.  
  1019.  The "fr_DontShow" filed points to a buffer in which you can copy  a wildcard
  1020.  pattern which tells the FileRequester NOT to list the FILES which match this
  1021.  pattern. A maximum of 32 bytes is allowed here.
  1022.  
  1023.  With "fr_LeftEdge" and "fr_TopEdge"  fields you can specify the  co-ordinates
  1024.  of the TopLeft corner of the FileRequester window on your screen. You should
  1025.  calculate  the position  so that  the FileRequester will fit on your screen.
  1026.  Using incorrect values will result in a "FREQ_CANT_OPEN" when  "FileRequest"
  1027.  is called. You can use the  "FREQ_WIDTH" and  "FREQ_HEIGHT" constants  which
  1028.  specify the FileRequester window width and height to calculate a position on
  1029.  your screen. The default settings are fr_LeftEdge = 10, fr_TopEdge = 15.
  1030.  
  1031.  In the "fr_Caller"  field you can put a pointer to a  window which calls the
  1032.  FileRequester.  If this field  is  initialized the  FileRequester will put a
  1033.  very small requester  in the  TopLeft corner  of this window  to disable the
  1034.  window  from receiving  IDCMP messages  while the FileRequester is still up.
  1035.  The requester is removed when the FileRequester is closed.  By default  this
  1036.  field is set to NULL.
  1037.  
  1038.  When you want the  FileRequester to  open on a  custom screen you must put a
  1039.  pointer to that screen in the "fr_Screen" field. This field defaults to NULL
  1040.  which tells the FileRequester to use the WorkBench screen.
  1041.  
  1042.  The "fr_Directory" field  points to a Directory structure  which is  already
  1043.  allocated and initialized by "AllocFreq" in which  the FileRequester  stores
  1044.  the directories it reads. This may also hold the last directory read  by the
  1045.  FileRequester even after the  FileRequester closed  depending  on whether the
  1046.  "FR_NoPreserve" bit was set or not. (see below).
  1047.  
  1048.  The "fr_Flags" field is used to switch certain functions in the FileRequester
  1049.  on or off. See below for an explanation of the possible flags. This defaults
  1050.  to "FR_ReturnVoid".
  1051.  
  1052.  The "fr_Colors[4]" fields can be used to define your own colors depending on
  1053.  whether the "FR_CustColor" flags is set or not. (see below).
  1054.  
  1055.  The "fr_Handle"  field is used  to return a  FileHandle to you is requested.
  1056.  (see below).
  1057.  
  1058.  Always set the "fr_Reserved" field to NULL because this field might  be used
  1059.  future version of the FileRequester/library.
  1060.  
  1061.  THE POSSIBLE FLAGS
  1062.  
  1063.  FR_NoPreserve
  1064.                   Normally when the FileRequester is closed the directory last
  1065.                   read will  be  kept in  the  "fr_Directory"  field  of  the
  1066.                   FileRequester  structure.  This has the advantage that, when
  1067.                   the FileRequester is recalled, the directory  does not have
  1068.                   to be read all over again. This  also has  the disadvantage
  1069.                   that  the directory  will take  up atleast  5 KByte of your
  1070.                   memory.  When the directory, on disk, changed the directory
  1071.                   in memory will not  show this change,  but if you press the
  1072.                   'HELP'  key when the  FileRequester is  active the complete
  1073.                   directory is re-read into memory.
  1074.  
  1075.  FR_NoDevs
  1076.                   Setting this flag  disables the FileRequester  from reading
  1077.                   and showing the mounted disk devices.
  1078.  
  1079.  FR_NoSort
  1080.                   Setting this flag  disables the FileRequester  from sorting
  1081.                   the entries of a directory by sort and alphabetical.
  1082.  
  1083.  FR_CustColor
  1084.                   If this flag is set the  FileRequester will  set the colors
  1085.                   defined in the  "fr_Colors[4]" fields  of the FileRequester
  1086.                   onto the screen it  appears on saving  the previous colors.
  1087.                   When the FileRequester is closed the old colors are reset.
  1088.  
  1089.  FR_ReturnOld
  1090.                   Setting this flag tells the  FileRequester to try  to open
  1091.                   the selected file if the user closed the requester with OK.
  1092.                   The file will be opened using  MODE_OLDFILE  and the handle
  1093.                   is  put  in  the  "fr_Handle"  field  of  the FileRequester
  1094.                   structure.
  1095.  
  1096.  FR_ReturnNew
  1097.                   Setting this flag tells the  FileRequester to try  to open
  1098.                   the selected file if the user closed the requester with OK.
  1099.                   The file will be opened using  MODE_NEWFILE  and the handle
  1100.                   is  put  in  the  "fr_Handle"  field  of  the FileRequester
  1101.                   structure.
  1102.  
  1103.  FR_ReturnReadWrite
  1104.                   Setting this flag tells the  FileRequester to try  to open
  1105.                   the selected file if the user closed the requester with OK.
  1106.                   The file will be opened using MODE_READWRITE and the handle
  1107.                   is  put  in  the  "fr_Handle"  field  of  the FileRequester
  1108.                   structure.
  1109.  
  1110.  FR_NoInfo        Setting this flag tells the  FileRequester not to show the
  1111.                   ".info" files.
  1112.  
  1113.  FR_ReturnVoid
  1114.                   This specifies NOT to open the selected file. default.
  1115.  
  1116.  
  1117.  POSSIBLE FILEREQUESTER RETURN CODES
  1118.  
  1119.  FREQ_OK         -> Everything OK. A  file  was  selected and,  if requested,
  1120.                     opened.
  1121.  
  1122.  FREQ_CANT_OPEN  -> The FileRequester could not be opened.  This  could  mean
  1123.                     that  not   enough  memory  was  available  or  that  the
  1124.                     "fr_LeftEdge" and/or "fr_TopEdge" fields contains invalid
  1125.                     values.
  1126.  
  1127.  FREQ_FILE_ERROR -> This means that the selected file failed to open.
  1128.  
  1129.  FREQ_CANCELED   -> This means that the user selected CANCEL or CLOSEWINDOW.
  1130.  
  1131.  ----------------------------------------------------------------------------
  1132.                                  IV. HISTORY
  1133.  ----------------------------------------------------------------------------
  1134.  
  1135.     VERSION 7--     -> TRASH !!!!
  1136.  
  1137.     VERSION 7.1     -> Still not Released.
  1138.  
  1139.     VERSION 7.2     -> The FileRequester now waits until the user selected
  1140.                        a gadget outside the file-selection area before it
  1141.                        starts to sort the entries.
  1142.  
  1143.     VERSION 7.3     -> "MatchPattern" had a bug resulting in the matching
  1144.                        always being case sensitive. This is now fixed.
  1145.  
  1146.     VERSION 7.4     -> I have put a pointer to the FileRequester window in
  1147.                        the "pr_WindowPtr" field of the Process structure
  1148.                        which results in the system requester appearing on
  1149.                        the same screen as the FileRequester. Also the
  1150.                        "DisplayBeep" function is called if a DOS error
  1151.                        occurred.
  1152.  
  1153.     VERSION 7.5     -> When the "fr_NoPreserve" is not set and the
  1154.                        FileRequester is called the old directory is
  1155.                        displayed. When the directory had changed this
  1156.                        is not shown in the list. Now you can press the
  1157.                        "HELP" key and the directory is re-read.
  1158.  
  1159.     VERSION 7.6     -> MAJOR BUG FOUND !! I did forget to call "Permit()"
  1160.                        after a call to "Forbid()" in the ReadDevs routine
  1161.                        of the FileRequester what resulted in some very
  1162.                        strange situations. This is now fixed (phew!).
  1163.                        VERY FIRST RELEASE !!!
  1164.  
  1165.     VERSION 7.7     -> Fixed a few minor problems (NOT BUGS!) in the
  1166.                        FileRequester.
  1167.  
  1168.     VERSION 7.8     -> Added "FR_NoInfo" flag for the FileRequester to
  1169.                        disable the showing of ".info" files.
  1170.  
  1171.     VERSION 8.1     -> Added the "FormatText" routine. C Headers now includes
  1172.                        Lattice pragmas. "AllocItem()" now returns NULL if one
  1173.                        try's to allocate a chunk bigger than a memory block.
  1174.  
  1175.  ----------------------------------------------------------------------------
  1176.                                  V. NOTES
  1177.  ----------------------------------------------------------------------------
  1178.  Bug reports and suggestions (please !) too me at the following address:
  1179.  
  1180.                                                 Jan van den Baard
  1181.                                                 Bakkerstraat 176
  1182.                                                 3082 HE Rotterdam
  1183.                                                 Holland
  1184.